package com.example.peibei.ui;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

public class BannerAdapter extends FragmentStateAdapter {
    private List<BannerFragment> list;

    public BannerAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    public void setList(List<BannerFragment> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return list.get(position);
    }

    @Override
    public int getItemCount() {
        if (list == null){
            return 0;
        }else {
            return list.size();
        }
    }
}
